# include <iostream>
# include <vector>
# include <algorithm>
using namespace std;

int a[105];
vector<vector<int>> vv;

void save(int m) {
	vector<int> v;
	//a下标从1开始
	for (int i = m; i; i--) {
		v.push_back(a[i]);
	}
	
	vv.push_back(v);
}

void dfs(int val, int m) {
	for (int i = 1; i <= val / 2; i++) {
		if (i >= a[m - 1]) { 
			a[m] = i;
			a[m + 1] = val - i;
			save(m + 1);
			dfs(val - i, m + 1);
		}
	}
}

int main() {
	int n;
	cin >> n;
	vv.push_back(vector<int>(1, n));
	
	//记录数据的a数组下标从1开始
	dfs(n, 1);
	
	sort(vv.begin(), vv.end(), greater<vector<int>>());
	for (int i = 0; i < vv.size(); i++) {
		for (int j = 0; j < vv[i].size(); j++) {
			cout << vv[i][j] << " ";
		}
		cout << endl;
	}
	
	cout << "total  = " << vv.size() << endl;
	
	return 0;
}
